package com.shuyu.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Data
@ApiModel(description = "审批流程明细")
@TableName("tbl_approval_process_detail")
public class ApprovalProcessDetail implements Serializable {
    private static final long serialVersionUID = 7895148697757161121L;
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    @ApiModelProperty(value = "审批流程ID")
    private Integer processId;
    @ApiModelProperty(value = "审批类型 1产品；2活动")
    private Integer type;
    private transient String  typeName;
    @ApiModelProperty(value = "操作类型 1上架 2 下架 3修改 4删除")
    private Integer operationType;
    @ApiModelProperty(value = "审批发起人ID")
    private Long createUserId;
    @ApiModelProperty(value = "执行流程ID")
    private Integer sourceId;
    @ApiModelProperty(value = "审批名字")
    private transient String sourceName;
    @ApiModelProperty(value = "当前流程审核用户ID")
    private Long auditingUserId;
    @ApiModelProperty(value = "审核状态0待审核 1审核通过 2审核未通过")
    private Integer auditingStatus;
    @ApiModelProperty(value = "审核驳回用户")
    private Long rejectUserId;
    @ApiModelProperty(value = "驳回原因")
    private String rejectReason;

    private transient List<ApprovalProcessFlow> flowList;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    private Date modifyTime;

    @ApiModelProperty(value = "是否允许审批 0不允许 1允许")
    private transient Integer allowApproval;

    public ApprovalProcessDetail() {
    }

    public ApprovalProcessDetail(Integer processId, Integer type, Long createUserId, Integer sourceId, Long auditingUserId, Integer auditingStatus, Date createTime,Integer operationType) {
        this.processId = processId;
        this.type = type;
        this.createUserId = createUserId;
        this.sourceId = sourceId;
        this.auditingUserId = auditingUserId;
        this.auditingStatus = auditingStatus;
        this.createTime = createTime;
        this.operationType = operationType;
    }

    public String getTypeName() {
        if(type==1){
            return "产品";
        } else if(type==2){
            return "活动";
        }
        return "未知";
    }
}
